package org.example.web;

import com.yc.damai.entity.DmUser;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * Company 源辰信息
 *
 * @author navy
 * @date 2024/6/20
 * Email haijunzhou@hnit.edu.cn
 */
@RestController
@RefreshScope
@Data
public class UserDo {

    @RequestMapping("user")
    public String other(HttpServletRequest request){
        return "user " + request.getServerPort();
    }


    @Value("${login.enable}")
    private String enable;

    @GetMapping("loginEnable")
    public String loginEnable(){
        return enable;
    }

    ///////////////////////////////////////////////////////////
    // add?a=xxx&b=xxx
    @RequestMapping("add")
    public int add(int a,int b){
        return a+b;
    }

    @RequestMapping("/showName/{name}")
    public String showName(@PathVariable String name){
        return "你好: " + name;
    }

    @RequestMapping("resetPwd")
    public DmUser setPwd(@RequestBody DmUser user, @RequestParam String pwd){
        user.setPassword(pwd);
        return user;
    }

}
